package com.dyp.global_exception_handler.ctr;

import java.beans.PropertyEditorSupport;

public class AddressEditor extends PropertyEditorSupport {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (text == null) {
            setValue(null);
        } else {
            // 移除所有非字母、数字、空格和标点符号的字符
            String cleaned = text.replaceAll("[^a-zA-Z0-9\\s,.-]",  "");
            setValue(cleaned.trim());
        }
    }
}